﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace Alicanto.Execution
{
    public class ExecutionContextInstance : ExecutionContext
    {
        internal ExecutionContext Clazz { get; private set; }
        private string _id;

        public ExecutionContextInstance(ExecutionContext clazz) : base(clazz.Scope, clazz.Domain, null)
        {
            _id = Guid.NewGuid().ToString();
            this.Clazz = clazz;

            // Construct
            foreach (KeyValuePair<string, ExecutionContextMember> pair in clazz._members)
            {
                this._members[pair.Key] = pair.Value.Compile(this);
            }
        }

        public override string ToString()
        {
            return _id;
        }
    }
}
